package com.springboot.blog.controller;

import com.springboot.blog.beans.SignIn;
import com.springboot.blog.config.utils.R;
import com.springboot.blog.dao.SignInMapper;
import com.springboot.blog.service.SignServiceimpl;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

@RestController
public class SigninController {

    @Resource
    SignServiceimpl signServiceimpl;
    @Resource
    SignInMapper signInMapper;

    @RequestMapping("user/signin")
    public R sig(HttpServletRequest request){
        String  userName = (String) request.getSession().getAttribute("userName");
        return signServiceimpl.signIn(userName);
    }

    @RequestMapping("user/signinDto")
    public R signinDto(HttpServletRequest request,String userName){
//        String  userName = (String) request.getServletContext().getAttribute("userName");
        return signServiceimpl.signInList(userName);
    }

    @RequestMapping("user/signinDto1")
    public R signinDto1(HttpServletRequest request,String userName){
        SignIn i = signInMapper.siginCount(userName);
        return R.ok().data("sings",i);
    }
}
